﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;
using Bot.Domain.Specifications;

namespace Bot.Domain.Categories.Service
{
    public class MessageAfterSeveralConsecutivePossibleAnswersInChannelDomainService : IMessageAfterSeveralConsecutivePossibleAnswersInChannelDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, MessageAfterSeveralConsecutivePossibleAnswersInChannel> _repository;

        public MessageAfterSeveralConsecutivePossibleAnswersInChannelDomainService(IRepository<Guid, MessageAfterSeveralConsecutivePossibleAnswersInChannel> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public MessageAfterSeveralConsecutivePossibleAnswersInChannel Create(MessageAfterSeveralConsecutivePossibleAnswersInChannel messageAfterSeveralConsecutivePossibleAnswersInChannel)
        {
            if (messageAfterSeveralConsecutivePossibleAnswersInChannel.Id == Guid.Empty)
            {
                messageAfterSeveralConsecutivePossibleAnswersInChannel.Id = Guid.NewGuid();
            }
            return _repository.Create(messageAfterSeveralConsecutivePossibleAnswersInChannel);
        }

        public MessageAfterSeveralConsecutivePossibleAnswersInChannel Get(Guid id)
        {
            return _repository.Get(id);
        }

        public MessageAfterSeveralConsecutivePossibleAnswersInChannel Update(MessageAfterSeveralConsecutivePossibleAnswersInChannelUpdateBo bo)
        {
            MessageAfterSeveralConsecutivePossibleAnswersInChannel messageAfterSeveralConsecutivePossibleAnswersInChannel = _repository.Get(bo.Id);
            //messageAfterSeveralConsecutivePossibleAnswersInChannel.Id = bo.Id;
            //messageAfterSeveralConsecutivePossibleAnswersInChannel.BotId = bo.BotId;
            messageAfterSeveralConsecutivePossibleAnswersInChannel.Channel = bo.Channel;
            messageAfterSeveralConsecutivePossibleAnswersInChannel.Message = bo.Message;
            messageAfterSeveralConsecutivePossibleAnswersInChannel.IfIncludeContactAgentOption = bo.IfIncludeContactAgentOption;

            _repository.Update(messageAfterSeveralConsecutivePossibleAnswersInChannel);

            return messageAfterSeveralConsecutivePossibleAnswersInChannel;

        }

        public IEnumerable<MessageAfterSeveralConsecutivePossibleAnswersInChannel> List()
        {
            return _repository.ListAll();
        }

        public void Delete(Guid id)
        {
            MessageAfterSeveralConsecutivePossibleAnswersInChannel messageAfterSeveralConsecutivePossibleAnswersInChannel = _repository.Get(id);

            _repository.Delete(messageAfterSeveralConsecutivePossibleAnswersInChannel);

        }

        public IEnumerable<MessageAfterSeveralConsecutivePossibleAnswersInChannel> GetByBotId(Guid botId)
        {
            var messageAfterSeveralConsecutivePossibleAnswersInChannels = _repository.List(new MessageAfterSeveralConsecutivePossibleAnswersInChannelFilterSpecification(botId));
            return messageAfterSeveralConsecutivePossibleAnswersInChannels;
        }
    }
}
